<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/8/24 0024
  Time: 10:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>

<table class="result-tab" width="100%">
    <tr>
        <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
        <th>ID</th>
        <th>阶段</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${requestScope.stages}" var="stage">
        <tr>
            <td class="tc">
                <input name="id[]" id="choose" value="${stage.id}" type="checkbox"></td>
            <td>
                    ${stage.id}
                    <%--<input name="ids[]" value="59" type="hidden">
                    <input class="common-input sort-input" name="ord[]" value="0" type="text">--%>
            </td>
            <td>${stage.stageName}</td>
            <td>
                <a class="link-del" href="#" data-id="${stage.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<div class="list-page">
    ${requestScope.pageInfo.pages}页
    <a href="#" data-pagenum="1">首页 </a>
    <c:if test="${requestScope.pageInfo.pageNum gt 1}">
        <a href="#" data-pagenum="${requestScope.pageInfo.pageNum-1}">上一页</a>
    </c:if>

    <c:forEach begin="1" end="${requestScope.pageInfo.pages}" var="i">

        <a href="#" data-pagenum="${i}"
                <c:if test="${i eq requestScope.pageInfo.pageNum}"> class="current" </c:if>>${i}</a>
    </c:forEach>

    <c:if test="${requestScope.pageInfo.pageNum lt requestScope.pageInfo.pages}">
        <a href="#" data-pagenum="${requestScope.pageInfo.pageNum+1}">下一页</a>
    </c:if>
    <a href="#" data-pagenum="${requestScope.pageInfo.pages}">尾页 </a>
    ${requestScope.pageInfo.pageNum}/${requestScope.pageInfo.pages}页
</div>
<script>
    var path = "${pageContext.request.contextPath}";
    $(function () {
        $(".link-del").click(function () {
            var id = $(this).data("id");
            var ansswer = confirm("确定删除吗？");
            if(ansswer){
                $.get(path+"/manage/stage/delete",
                    {id:id},
                    function () {
                        $(this).parent().parent().remove();
                    }.bind(this));
            }
            else {
                return false;
            }
        });
    });
</script>